package com.baidu.fsg.client;

import com.baidu.fsg.uid.UidGenerator;
import com.baidu.fsg.uid.impl.CachedUidGenerator;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import javax.annotation.Resource;

/**
 * Test for {@link CachedUidGenerator}
 *
 * @author yutianbao
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:id-generator-spring.xml"})
public class Test {

    @Resource(name = "defaultUidGenerator")
    private UidGenerator defaultUidGenerator;

    @Resource(name = "cachedUidGenerator")
    private UidGenerator cachedUidGenerator;

    @org.junit.Test
    public void test1() {
        long uid = defaultUidGenerator.getUID();
        String parsedInfo = defaultUidGenerator.parseUID(uid);
        System.out.println(uid);
        System.out.println(parsedInfo);
    }

    @org.junit.Test
    public void test2() {
        long uid = cachedUidGenerator.getUID();
        String parsedInfo = cachedUidGenerator.parseUID(uid);
        System.out.println(uid);
        System.out.println(parsedInfo);
    }

}
